export default function (pageW, pageH, id) {
    const el = document.getElementById(id)
    el.style.cssText += `
            ;position: absolute;
            left: 50%;
            top: 50%;
            width: ${pageW}px;
            height: ${pageH}px;
            transform-origin: left top;
        `
    return function () {
        if (!el) return false

        const originW = document.body.clientWidth
        const originH = document.body.clientHeight
        const origeScale = originW / originH
        const bgScale = pageW / pageH

        const _scale = origeScale > bgScale ? (originH / pageH) : (originW / pageW)
        el.style['-webkit-transform'] = `scale(${_scale}) translate(-50%, -50%)`
        el.style.transform = `scale(${_scale}) translate(-50%, -50%)`
    }
}